package org.openjsonp.json;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.util.Map;

import javax.json.JsonReader;
import javax.json.JsonReaderFactory;

/**
 * Implementation of {@link javax.json.JsonReaderFactory JsonReaderFactory}.
 * 
 */
public class JsonReaderFactoryImpl implements JsonReaderFactory {

	private final Map<String, ?> config;

	public JsonReaderFactoryImpl(Map<String, ?> config) {
		this.config = config;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public JsonReader createReader(Reader reader) {
		return new JsonReaderImpl(reader);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public JsonReader createReader(InputStream in) {
		return new JsonReaderImpl(new InputStreamReader(in));
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public JsonReader createReader(InputStream in, Charset charset) {
		return new JsonReaderImpl(new InputStreamReader(in, charset));
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Map<String, ?> getConfigInUse() {
		return config;
	}

}
